//
//  GFFoodmarkDataCollectionViewCell.m
//  GoodFood
//
//  Created by dllo on 15/11/4.
//  Copyright © 2015年 荣伟峰. All rights reserved.
//

#import "GFFoodmarkDataCollectionViewCell.h"

@interface GFFoodmarkDataCollectionViewCell ()

@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UILabel *yearLabel;
@property (nonatomic, strong) UILabel *countLabel;

@end

@implementation GFFoodmarkDataCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        self.contentView.backgroundColor = [UIColor colorWithRed:0.902 green:0.105 blue:0.155 alpha:1.000];
        
        self.timeLabel = [[UILabel alloc] init];
        self.timeLabel.font = [UIFont systemFontOfSize:20];
        self.timeLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:self.timeLabel];
        
        self.countLabel = [[UILabel alloc] init];
        self.countLabel.textAlignment = NSTextAlignmentRight;
        self.countLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:self.countLabel];
        
        self.yearLabel = [[UILabel alloc] init];
        self.yearLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:self.yearLabel];
        
    }
    return self;
    
}

-(void)setModel:(GFFoodmarkModel *)model {
    
    if (_model != model) {
        _model = model;
    }
    
    self.timeLabel.frame = CGRectMake(5, 0, (ScreenWidth - 40) / 3 - 5, ScreenWidth / 15);
    NSString *date = [model.date substringFromIndex:5];
    date = [date stringByReplacingOccurrencesOfString:@"-" withString:@"月"];
    self.timeLabel.text = [NSString stringWithFormat:@"%@日", date];
    
    self.yearLabel.frame = CGRectMake(5, ScreenWidth / 15, (ScreenWidth - 40) / 3 - 5, ScreenWidth / 20);
    NSArray *yearArr = [model.date componentsSeparatedByString:@"-"];
    self.yearLabel.text = [NSString stringWithFormat:@"%@年", yearArr[0]];
    
    self.countLabel.frame = CGRectMake(0, (ScreenWidth - 40) / 3 - ScreenWidth / 20, (ScreenWidth - 40) / 3, ScreenWidth / 20);
    self.countLabel.text = [NSString stringWithFormat:@"%@道美食", [model.count stringValue]];

}

@end
